#from .ollama import OllamaProvider
from typing import Dict, Union, List
from typing_extensions import Literal 
import os
from abc import ABC, abstractmethod
from mcp.types import Tool


from ..common import ModelParameter

DEFAULT_PROVIDER="ollama"


class BaseProvider(ABC):
    provider: Literal["ollama", "openai"]
    def __init__(self, model_param: ModelParameter):
        self.provider=model_param.provider
        if self.provider is None:
            self.provider=DEFAULT_PROVIDER
        self.api_key=model_param.api_key or os.getenv("OPENAI_API_KEY")
        self.base_url=model_param.base_url
        self.model=model_param.model
        self.max_retries=model_param.max_retries
        self.model_parameter=model_param
        self.stream_options=model_param.stream_options
        self.extra_body=model_param.extra_body
    @abstractmethod
    def format_tool(self, tool: Tool):
        pass

    @abstractmethod
    async def chat(self, messages: List[Dict], stream: bool = False):
        pass

    @abstractmethod
    async def response(self, messages: List[Dict], stream: bool = False):
        pass

    @abstractmethod
    async def get_embedding(self, text: str):
        pass
